package com.dzm.core.controller.api;


import com.dzm.common.result.R;
import com.dzm.core.service.IUserInfoService;
import com.dzm.core.vo.LoginVo;
import com.dzm.core.vo.UserInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户基本信息 前端控制器
 * </p>
 *
 * @author Dzm
 * @since 2024-09-20
 */
@RestController
@RequestMapping("/api/core/userInfo")
public class UserInfoController {

    @Autowired
    private IUserInfoService userInfoService;

    @PostMapping("/login")
    public R login(@RequestBody LoginVo loginVo, HttpServletRequest request) {
        String ip = request.getLocalAddr();
        UserInfoVo userInfo = userInfoService.login(loginVo, ip);

        return R.ok().data("userInfo", userInfo);
    }

}
